% process parameter in to structure fields
% field names in lower case
function par = process_parameter(par, varargin)
    if length(varargin) == 1, return; end
    par_names = fieldnames(par);
    if rem(length(varargin),2) == 1
        error(['Number of parameters should be even. ' ...
               num2str(length(varargin))])
        %varargin;
    end
    for i=1:2:length(varargin)
        field = lower(varargin{i});
        val = varargin{i+1};
        if ~any(strcmp(par_names, field)), continue; end
        par.(field) = val;
    end    
end
